﻿/// <summary>
///   点クラス
/// </summary>

using System;
using System.Collections.Generic;

namespace Geometry
{
    class Point : IComparable<Point>
    {
	/// <summary>
	///   x 座標
	/// </summary>
	public int x  { get; set; }

	/// <summary>
	///   y 座標
	/// </summary>
	public int y  { get; set; }


	/// <summary>
	/// 座標値 (x, y) を与えて初期化。
	/// </summary>
	/// <param name="x">x 座標値</param>
	/// <param name="y">y 座標値</param>
	public Point(int x, int y)
	{
	    this.x = x;
	    this.y = y;
	}

	/// <summary>
	///   コピーして初期化。
	/// </summary>
	/// <param name="other">コピー元</param>
	public Point(Point src)
	    :this(src.x, src.y)
	{}

	/// <summary>
	///   比較メソッド
	/// </summary>
	public int CompareTo(Point other)
	{
	    if (other == null) return 1;
	     
	    if (other.x == x) {
		return y - other.y;
	    }	
	    return x - other.x;
	}


	/// <summary>
	///   文字列化メソッド
	/// </summary>
	public override string ToString()
	{
	    return "(" + x + ", " + y + ")";
	}
	
    } // Point

}
